<template>
  <div class="layout">
    <Topnav class="nav" toggleAsideButtonVisible></Topnav>
    <div class="content">
      <aside v-if="asideVisible">
        <h2>组件列表</h2>
        <ol>
          <li>
            <router-link to="/doc/switch">Switch 组件</router-link>
          </li>
          <li>
            <router-link to="/doc/button">Button 组件</router-link>
          </li>
          <li>
            <router-link to="/doc/modal">Modal 组件</router-link>
          </li>
          <li>
            <router-link to="/doc/tabs">Tabs 组件</router-link>
          </li>
        </ol>
      </aside>
      <main>
        <router-view></router-view>
      </main>
    </div>
  </div>
</template>

<script lang="ts">
import { Ref, inject } from 'vue';
import Topnav from '../gallery/Topnav.vue';

export default {
  components: {
    Topnav,
  },
  setup () {
    const asideVisible = inject<Ref<boolean>>('asideVisible');

    return { asideVisible }
  }
}
</script>

<style lang="scss" scoped>


  .layout {
    display: flex;
    flex-direction: column;
    height: 100vh;

    > .nav {
      flex-shrink: 0;
    }

    > .content {
      flex-grow: 1;
      padding-top: 60px;
      padding-left: 156px;
      @media (max-width: 500px) {
        padding-left: 0; 
      }
    }
  }

  .content {
    display: flex;
    
    > aside {
      flex-shrink: 0;
    }

    > main {
      flex-grow: 1;
      padding: 16px;
      background: white;
    }
  }

  aside {
    background: lightblue;
    width: 150px;
    padding: 16px 0;
    position: fixed;
    top: 0;
    left: 0;
    padding-top: 70px;
    height: 100%;
    z-index: 20;

    > h2 {
      margin-bottom: 4px;
      padding: 0 16px;
    }
    
    > ol {

      > li {
        display: flex;
        align-items: center;
        height: 32px;

        > a {
          flex: 1;
          padding: 4px 16px;
        }

        .router-link-active {
          display: block;
          color: #1890FF;
          background-color: white;
          padding: 4px 16px;
        }
      }
    }
  }

  main {
    overflow: auto;
  }

</style>